#region Copyright

//  ======================================================
//      Copyright (c) 2011 Toulr All rights reserved.
//     
//      The use and distribution terms for this software are contained in the file
//      named license.txt, which can be found in the root of this distribution.
//      By using this software in any fashion, you are agreeing to be bound by the
//      terms of this license.
//     
//     You must not remove this notice, or any other, from this software.
//  ======================================================

#endregion

namespace Toulr.Util.Security
{
    /// <summary>
    ///   Interface to compute a data checksum used by checked input/output streams.
    ///   A data checksum can be updated by one byte or with a byte array. After each
    ///   update the value of the current checksum can be returned by calling
    ///   <code>getValue</code>. The complete checksum object can also be reset
    ///   so it can be used again with new data.
    /// </summary>
    public interface IChecksum
    {
        /// <summary>
        ///   Returns the data checksum computed so far.
        /// </summary>
        long Value { get; }

        /// <summary>
        ///   Resets the data checksum as if no update was ever called.
        /// </summary>
        void Reset();

        /// <summary>
        ///   Adds one byte to the data checksum.
        /// </summary>
        /// <param name = "value">
        ///   the data value to add. The high byte of the int is ignored.
        /// </param>
        void Update(int value);

        /// <summary>
        ///   Updates the data checksum with the bytes taken from the array.
        /// </summary>
        /// <param name = "buffer">
        ///   buffer an array of bytes
        /// </param>
        void Update(byte[] buffer);

        /// <summary>
        ///   Adds the byte array to the data checksum.
        /// </summary>
        /// <param name = "buffer">
        ///   The buffer which contains the data
        /// </param>
        /// <param name = "offset">
        ///   The offset in the buffer where the data starts
        /// </param>
        /// <param name = "count">
        ///   the number of data bytes to add.
        /// </param>
        void Update(byte[] buffer, int offset, int count);
    }
}